package com.jiaodian.auth.service.impl;

import cn.hutool.crypto.symmetric.SymmetricAlgorithm;
import cn.hutool.crypto.symmetric.SymmetricCrypto;
import com.jiaodian.auth.service.IRegisterService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @Author:princess
 * @Date:2024/10/9-10-09-11:31
 */
@Service
@Slf4j
public class RegisterServiceImpl implements IRegisterService {

    /**
     * 邮件发送服务器地址
     */
    private String SystemUrl = "http://127.0.0.1/";

    /**
     * 校验接口
     */
    private String VerifyUrl = "/auth/register/v1/check";

    /**
     * 定义密钥
     * 长度必须是 16、24或者32字节
     */
    private String SecretKey = "2747392938472302";

    @Override
    public String sendVerifyEmail(String email) {
        //对邮箱地址进行加密
        SymmetricCrypto symmetricCrypto = new SymmetricCrypto(SymmetricAlgorithm.AES, SecretKey.getBytes());
        //加密成16进制
        String encryptHex = symmetricCrypto.encryptHex(email);
        //邮件地址（配置中心）
        String emailAddress = SystemUrl + VerifyUrl + "?check=" + encryptHex;
        log.info("最终地址："+ emailAddress);
        return emailAddress;
    }
}
